package com.itheima.health.controller;

import com.itheima.health.entity.QueryPageBean;
import com.itheima.health.entity.Result;
import com.itheima.health.pojo.CheckItem;
import com.itheima.health.service.CheckItemService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("checkitem")
@Api(tags = "传智健康预约模块之检查项管理")
public class CheckItemController {

    @Reference
    private CheckItemService checkItemService;


    @PostMapping("saveOrUpdate")
    public Result saveOrUpdate(@RequestBody CheckItem checkItem){
        return  new Result(checkItemService.saveOrUpdate(checkItem));
    }

    @GetMapping("findAll")
    @ApiOperation(value = "查询功能",notes = "检查项查询列表信息")
    public Result  findAll(){
        return  new Result(checkItemService.list());
    }

//修改和添加
    @PostMapping("findPage")
    @ApiOperation(value = "查询功能",notes = "检查项查询列表信息")
    public Result findPage(@RequestBody QueryPageBean queryPageBean){
        return  new Result(checkItemService.findPage(queryPageBean));
    }
    @DeleteMapping("delete/{id}")
    @ApiOperation(value = "逻辑删除功能",notes = "根据id 删除指定检查项")
    public Result   delete(@PathVariable("id") int id){
        CheckItem checkItem = new CheckItem();
        checkItem.setId(id);
        checkItem.setIs_delete(1);
        return  new Result(checkItemService.updateById(checkItem));
    }
//    @DeleteMapping("deleteById/{id}")
//    public Result deleteById(@RequestParam("id") int id){
//        return new Result(checkItemService.updateCheckLtemById(id));
//    }

}
